<template>
  <div class="gs-wrap">
    <div class="gs-nav">我要卖货 > 红人解析</div>
    <div class="hp-content">
      <div class="hp-content-left" v-loading="loading">
        <div class="hp-content-left-title">{{listLeft.nickName}}直播解析</div>
        <div class="hp-content-left-list">
          <div class="hp-content-left-item">
            <!-- <div class="hp-content-item-title">
              <img :src="listLeft.headImg" alt="加载中">
            </div> -->
            <p class="hp-content-item-txt" v-html="listLeft.content"></p>
            <!-- <img src="http://www.hdtun.com/files/83bd026b-2df1-4b64-b6a9-5fb8b903a3e5.PNG" alt=""> -->
          </div>
        </div>
      </div>
      <div class="hp-content-right">
        <div class="hp-content-right-title">最近</div>
        <div class="hp-right-list">
          <div class="hp-right-item" @click="clkNickName(item.id)" v-for="item in listRight" :key="item.id">
            <img v-lazy="item.headImg" alt="请求中">
            <p class="username-list" :title="item.nickName">{{item.nickName}}</p>
          </div>
        </div>
        <div class="hp-paging">
          <div class="hp-paging-pre-btn" :class="{'text-active': page === 1}"  @click="preP(userId)"><</div>
          <div class="hp-paging-center">{{page}}/{{pages}}</div>
          <div class="hp-paging-next-btn" :class="{'text-active': page == pages}" @click="nextP(userId)">></div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  async fetch({store}) {
    await store.commit('setToolsIndex',4)
  },
  layout: 'internalouts',
  mounted() {
  },
  data() {
    return {
      listLeft:{},  //左边的数据
      listRight:[], //右边的数据
      loading:false, //加载动画
      loading1:false, //分页加载动画
      pageSize:10, //每页条数
      page:1, //每页
      pages:0,  //总页数
      total:2, //总的条数
      userId:0,  //用户id
    }
  },
  methods: {
    getData(){ //红人解析
      // this.loading = true
      let params ={
        pageSize:this.pageSize,  //每页条数
        pageNum:this.page,  //第一页
        pages:this.pages, //总页数
        total:this.total, //总的条数
        id:this.userId, //用户ID
      }
      this.$axios.$post('anchorAnalysis',params).then(res => {
          // this.loading = false
        if(res.status === 200 ){
          this.listLeft = res.obj.defaultSkill //左边的列表数据
          this.listRight = res.obj.anchorSkillList.list //右边的分页数据
          this.pages = res.obj.anchorSkillList.pages //获取总页数
          this.total = res.obj.anchorSkillList.total //拿到总条数
          this.userId = res.obj.anchorSkillList.id //拿到用户ID
        }else{
          this.$message({
            message:res.msg,  
            type:'warning'
          })
        }
      })
        .catch(error => {
          // this.loading = false
          this.$message({
            message:'请求失败',  
            type:'warning'
          })
        })
    },
    nextP(id){  //下一页
      //  if(this.page < this.pages){
      if(this.page < this.pages){
        this.page++
        this.userId = id
        this.getData()
      }
    },
    preP(id){ //上一页
      if(this.page > 1){
        this.page--
        this.userId = id
        this.getData()
      }
    },
    clkNickName(id){  //点击昵称，对应的左边的数据变,需要传入id this.userId =id
      this.userId = id
      this.getData()
    }
  },
  mounted(){
    this.getData()
  }
}
</script>

<style scoped>
  .gs-nav {
    font-size: 14px;
    color: #999;
    height: 50px;
    line-height: 50px;
  }
  .hp-content {
    display: flex;
    justify-content: space-between;
  }
  .hp-content-left {
    flex:1;
    background: #fff;
    padding: 20px;
    border-radius: 5px;
    margin-right:20px;
  }
  .hp-content-left-title {
    color: #333;
    font-size: 16px;
    text-align:center;
  }
  .hp-content-left-item {
    margin-top: 20px;
  }
  .hp-content-item-title {
    height:300px ;
    color: #666;
    font-size: 16px;
    line-height: 44px;
    padding: 20px 0;
  }
  .hp-content-item-title{
    width:100%;
    height:100%;
  }
  .hp-content-item-txt {
    font-size: 14px;
    color: #666;
    line-height: 2;
    margin-top: 20px;
    text-align: justify;
    letter-spacing:1.5px;
  }
  .hp-content-right {
    background: #fff;
    border-radius: 5px;
    width: 222px;
    padding-bottom:20px;
  }
  .hp-content-right-title {
    padding:  0 20px;
    height: 53px;
    line-height: 53px;
    color: #333;
    font-size: 14px;
    position: relative;
    border-bottom: 1px solid #f4f4f4;
  }
  .hp-content-right-title::before {
    content: '';
    background: #0096e6;
    width: 3px;
    height: 26px;
    position: absolute;
    left: 0;
    top: 13px;
  }
  .hp-right-list {
    margin-top: 8px;
    margin-left: 20px;
  }
  .hp-right-item {
    display: flex;
    align-items: center;
    width: 150px;
    cursor: pointer;
    margin: 10px auto;
  }
  .hp-right-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }
  p{
    display:inline-block;
  }
  .hp-right-item p.username-list {
    width:90px;
    height:40px;
    line-height:40px;
    font-size: 14px;
    color: #333;
    margin-left: 20px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .hp-paging {
    display: flex;
    justify-content: center;
    margin-top: 30px;
    align-items: center;
  }
  .hp-paging-pre-btn,.hp-paging-next-btn{
    border: 1px solid #e1e1e1;
    background: #f4f4f4;
    box-sizing: border-box;
    color: #666;
    padding: 6px 8px;
    cursor: pointer;
    user-select: none;
    font-family:simsun;
    font-weight:bold;
    margin:0 10px;
  }
  .text-active{
    color:#c2c2c2;
  }
  .hp-paging-center {
    color: #666;
    font-size: 16px;
  }
  .hp-content-left-item{
    text-align:center;
  }
  .hp-content-left-item img {
    display:inline-block;
    width:850px;
  }
  @media screen and (min-width:1200px) and (max-width:1366px){
    .hp-content-left-item img {
      width:658px;
    }
  }
  @media screen and (max-width:1200px){
    .hp-content-left-item img {
      width:658px;
    }
  }
</style>
